package com.crm.dao.mapper.customMapper.returnMoneyManagerCustomMapper;

import com.crm.model.entity.finishOrderProduct.FinishOrderProduct;
import com.crm.model.entity.finishOrderProduct.PersonalPerformanceAnalysis;
import com.crm.model.vo.customerManager.FinishOrderCustomerVO;
import com.crm.model.vo.finishOrderProduct.ExportOppFinishProductVO;
import com.crm.model.vo.finishOrderProduct.FinishOrderProductVO;
import com.crm.model.vo.finishOrderProduct.ImportOppFinishProductVO;
import com.crm.model.vo.productManager.AnalyseFinishOrderProductVO;
import com.crm.model.vo.productManager.ProductAnalyseVO;
import com.crm.model.vo.returnMoney.CustFinanceProductOderVO;
import com.crm.model.vo.returnMoney.ProductOfCustomerVO;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.List;


/**
 * 订单完成的产品
 */
public interface FinishOrderProductCustomMapper {

    /**
     * 客户详情产品明细
     *
     * @param deleteStatus      删除状态  0
     * @param customerId        客户id
     * @param productCategories 产品分类 0:非会员;1:会员
     * @param sortOrder         分组类型
     * @return
     */
    List<CustFinanceProductOderVO> finishOrderProductList(@Param("deleteStatus") short deleteStatus, @Param("customerId") String customerId, @Param("productCategories") String productCategories, @Param("sortOrder") String sortOrder);

    /**
     * 客户详情产品明细
     *
     * @param deleteStatus      删除状态  0
     * @param customerId        客户id
     * @param sortOrder         分组类型
     * @return
     */
    List<CustFinanceProductOderVO> csdFinishOrderProductList(@Param("deleteStatus") short deleteStatus, @Param("customerId") String customerId, @Param("sortOrder") String sortOrder);

    List<CustFinanceProductOderVO> getMemberProductListByOrderId(@Param("deleteStatus") short deleteStatus, @Param("orderId") String orderId, @Param("productCategories") String productCategories);

    /**
     * 根据订单id清空产品
     *
     * @param productOrderId
     */
    void delOrderProductByOrderId(@Param("orderId") String productOrderId);

    /**
     * 查询会员产品数量list
     *
     * @param dateUnit
     * @param accountId
     * @return
     */
    List<String> selectVipProductCountList(@Param("dateUnit") Integer dateUnit, @Param("accountId") String accountId, @Param("startDate") String startDate, @Param("endDate") String endDate);

    /**
     * 查询非会员产品数量list
     *
     * @param dateUnit
     * @param accountId
     * @return
     */
    List<String> selectProductCountList(@Param("dateUnit") Integer dateUnit, @Param("accountId") String accountId, @Param("startDate") String startDate, @Param("endDate") String endDate);

    /**
     * 查询产品额度list
     *
     * @param dateUnit
     * @param accountId
     * @return
     */
    List<String> selectProductPriceCountList(@Param("dateUnit") Integer dateUnit, @Param("accountId") String accountId, @Param("startDate") String startDate, @Param("endDate") String endDate);

    /**
     * 查询产品总数量、额度
     * @param dateUnit
     * @param accountId
     * @param type
     * @return
     */
    ProductAnalyseVO selectProductCountAndPrice(@Param("dateUnit") Integer dateUnit, @Param("accountId") String accountId, @Param("type") int type, @Param("startDate") String startDate, @Param("endDate") String endDate);

    /**
     * 查询产品总数量、额度（查询finish表）
     * @param dateUnit
     * @param accountId
     * @param type
     * @param startDate
     * @param endDate
     * @return
     */
    ProductAnalyseVO queryFinishProductCountAndPrice(@Param("dateUnit") Integer dateUnit, @Param("accountId") String accountId, @Param("type") int type, @Param("startDate") String startDate, @Param("endDate") String endDate);


    /**
     * 订单完成的产品列表统计
     *
     * @param dateUnit
     * @param order
     * @param accountId
     * @return
     */
    List<AnalyseFinishOrderProductVO> selectAnalyseFinishOrderProductList(@Param("dateUnit") Integer dateUnit, @Param("order") String order, @Param("accountId") String accountId);


    /**
     * 业绩清单（主查询finish表）
     * @param dateUnit
     * @param order
     * @param accountId
     * @return
     */
    List<AnalyseFinishOrderProductVO> getPerformanceList(@Param("dateUnit") Integer dateUnit, @Param("order") String order, @Param("accountId") String accountId);


    /**
     * 查询用户销售总额度
     *
     * @param dateUnit
     * @param accountId
     * @return
     */
    BigDecimal getUserProductPriceCount(@Param("dateUnit") Integer dateUnit, @Param("accountId") String accountId);

    /**
     * 客户详情产品等级
     *
     * @param deleteStatus      删除状态  0
     * @param customerId        客户id
     * @param productCategories 产品分类 0:非会员:1:会员
     * @return
     */
    Integer productMembershipLevel(@Param("deleteStatus") short deleteStatus, @Param("customerId") String customerId, @Param("productCategories") String productCategories);


    /**
     * @Description: 根据产品编码查询客户信息
     * @Param: [productCode]
     * @Return: java.util.List<com.crm.model.vo.customerManager.FinishOrderCustomerVO>
     * @Author: lixq-fs
     * @Date: 2021/6/2
     **/
    List<FinishOrderCustomerVO> selectCustomersByProductCode(@Param("productCode") String productCode,
                                                             @Param("accountId") String accountId);


    /**
     * @Description: 根据客户id获取客户下产品信息
     * @Param: [customerId]
     * @Return: java.util.List<com.crm.model.vo.returnMoney.ProductOfCustomerVO>
     * @Author: lixq-f
     * @Date: 2021/6/3
     **/
    List<ProductOfCustomerVO> selectProductsByCustomerId(@Param("customerId") String customerId,
                                                         @Param("productCode") String productCode);


    /**
     * @Description: 根据非会员产品编号消费产品
     * @Param: [productNumLst]
     * @Return: void
     * @Author: lixq-f
     * @Date: 2021/6/11
     **/
    Integer consumeNoMember(@Param("productNumLst") List<String> productNumLst);


    /**
     * @Description: 根据产品号列表查询产品
     * @Param: [productNumLst]
     * @Return: java.util.List<com.crm.model.vo.returnMoney.ProductOfCustomerVO>
     * @Author: lixq-f
     * @Date: 2021/6/11
     **/
    List<ProductOfCustomerVO> queryProductsByProductNumLst(@Param("productNumLst") List<String> productNumLst);



    /**
     * @Description: 根据产品号修改剩余服务次数
     * @Param: [productNum, remainNum]
     * @Return: java.lang.Boolean
     * @Author: lixq-f
     * @Date: 2021/7/21
     **/
    Boolean updateServiceTimesByProductNum(@Param("productNum") String productNum,
                                           @Param("remainNum") int remainNum);

    /**
     * 根据订单id查询总业绩金额
     * @param productOrderId
     * @return
     */
    BigDecimal selectGradeMoneyByOrderId(@Param("orderId") String productOrderId);

    /**
     * 查询业绩金额
     * @param companyId
     * @param dateType
     * @return
     */
    BigDecimal selectGradeMoneyCount(@Param("companyId") String companyId,@Param("dateUnit") Integer dateType);

    /**
     * 根据订单id查询提成金额
     * @param orderId
     * @return
     */
    BigDecimal selectFinishOrderProductRoyaltyMoneyCountByOrderId(@Param("orderId")String orderId);

    void delFinishByOrderId(@Param("orderId") String productOrderId);


    List<FinishOrderProductVO> selectProductSceneList(@Param("order") String order, @Param("customerId") String customerId);

    Integer selectFinishProductCountByOrderId(@Param("orderId") String orderId);

    /**
     * 清空订单下finish表回款数据
     * @param productOrderId
     * @param accountId
     */
    void clearFinishReturnMoneyInfoByOrderId(@Param("orderId")String productOrderId, @Param("accountId") String accountId);

    /**
     * 根据订单id产品id查询finish表产品信息
     * @param productId
     * @param productOrderId
     * @return
     */
    List<CustFinanceProductOderVO> selectFinishOrderProductByProductId(@Param("productId") String productId,@Param("orderId") String productOrderId);

    /**
     * 查询客户下的产品
     * @param customerId   客户Id
     * @return
     */
    List<CustFinanceProductOderVO> selectProductByCustomerId(@Param("customerId") String customerId);

    /**
     * 根据产品号修改产品状态和到款时间
     * @Param finishOrderProduct
     * @Author xielinqi
     * @Date 3:13 下午 2021/11/8
     */
    Boolean updateArriveTimeAndOtherSelectiveInfo(FinishOrderProduct finishOrderProduct);

    /**
     * 根据订单id修改产品状态和到款时间
     * @Param finishOrderProduct
     * @Author xielinqi
     * @Date 6:57 下午 2021/11/9
     */
    int updateArriveTimeAndOtherSelectiveInfoByProductOrderId(FinishOrderProduct finishOrderProduct);

    /**
     * 根据订单id和产品状态查询产品列表
     * @Param productOrderId
     * @Param productStatus
     * @Author xielinqi
     * @Date 9:06 上午 2021/11/15
     */
    List<FinishOrderProductVO> selectListByProductOrderId(@Param("productOrderId") String productOrderId, @Param("productStatus") String productStatus);

    /**
     * 根据优惠券ID及客户ID查询记录
     * @param couponId
     * @param customerId
     * @return
     */
    List<FinishOrderProduct> selectListByCouponIdAndCustomerId(String couponId, String customerId);


    List<PersonalPerformanceAnalysis> getPersonalPerformanceAnalysis(@Param("dateStr") String dateStr, @Param("accountId") String accountId);

    /**
     * opp客户购买产品
     * @param list
     * @return
     */
    List<ExportOppFinishProductVO> exportOppCustomerFinishProduct(@Param("list") List customerList);
}
